﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

namespace linkouqs.Gamekit
{
    public class SelectCharacterPanel:BasePanel
    {
        private CanvasGroup canvasGroup;

        public void Start()
        {
         
            if (canvasGroup == null) canvasGroup = GetComponent<CanvasGroup>();
        }

        public override void OnEnter()
        {
            base.OnEnter();
            if (canvasGroup == null) canvasGroup = GetComponent<CanvasGroup>();
            canvasGroup.alpha = 1;
            canvasGroup.blocksRaycasts = true;

            Vector3 temp = transform.localPosition;
            temp.x = 600;
            transform.localPosition = temp;
            transform.DOLocalMoveX(0, 0.5f);
        }

        public override void OnExit()
        {
            base.OnExit();
            canvasGroup.blocksRaycasts = false;

            transform.DOLocalMoveX(600, 0.5f).OnComplete(() => canvasGroup.alpha = 0);
        }

        /// <summary>
        /// 
        /// </summary>
        public override void OnPause()
        {
            canvasGroup.blocksRaycasts = false;
        }

        public override void OnResume()
        {
            canvasGroup.blocksRaycasts = true;
        }

    }
}
